import { SEARCH_BLUR,SEARCH_FOCUS,CHANGE_LIST,MOUSE_ENTER,MOUSE_LEAVE, CHANGE_PAGE,TOGGLE_FIXED } from "./constants";
import axios from "axios"

export const searchFocus = () => ({
	type: SEARCH_FOCUS
});

export const searchBlur = () => ({
	type: SEARCH_BLUR
});
export const changeList=(data)=>({
    type:CHANGE_LIST,
    data: (data),
    totalPage:Math.ceil(data.length/10)
})
export const changePage=(page)=>({
    type:CHANGE_PAGE,
    page:page

})
export const getList=()=>{
    return (dispatch)=>{
        axios.get("/api/headerList.json").then((res)=>{
            console.log(res);
            dispatch(changeList(res.data.data))

        })
    }

}
export const mouseEnter=()=>({
    type:MOUSE_ENTER,

})
export const mouseLeave=()=>({
    type:MOUSE_LEAVE,

})

export const changeFixed=(flag)=>({
    type:TOGGLE_FIXED,
    flag
})
